package com.ysu.shop.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ysu.shop.pojo.Goods;
import com.ysu.shop.mapper.GoodsMapper;
import com.ysu.shop.service.IGoodsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 耿志龙
 * @since 2020-10-01
 */
@Service
public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements IGoodsService {

    @Resource
    private GoodsMapper goodsMapper;

    @Override
    public List<Map<String, Object>> getIndexGood(String ids) {
        QueryWrapper<Goods> wrapper= new QueryWrapper<>();
        wrapper.eq("active","1").inSql("category_id", ids);
        wrapper.gt("stock",0);
        wrapper.last("limit 6");
        return goodsMapper.getIndexGood(wrapper);
    }
}
